# 作者: 陈其志 
# 2025年02月20日21时15分24秒 
# 2716847110@qq.com
# 继承加重写来实现多态:调用相同的逻辑，实现不同的行为
class Dog(object):

    def __init__(self, name):
        self.name = name

    def game(self):
        print(f"{self.name}正在玩耍")


class XiaoTianDog(Dog):
    def game(self):
        print(f"{self.name}在天上飞")


class Person:
    def __init__(self, name):
        self.name = name

    # 多态
    def game_with_dog(self, dog: Dog):
        print(f"{self.name} 和 {dog.name}一起玩耍")
        dog.game()


wangcai = Dog('旺财')
xiaotianquan = XiaoTianDog("哮天犬")
xiaoming = Person("小明")
xiaoming.game_with_dog(wangcai)
xiaoming.game_with_dog(xiaotianquan)
xiaoming.game_with_dog(xiaoming)
